//
//  BuyDetailFooterView.m
//  体育商城
//
//  Created by  on 2022/9/23.
//

#import "BuyDetailFooterView.h"
@interface BuyDetailFooterView()
@property (strong, nonatomic) IBOutlet UITextView *input;
@property (strong, nonatomic) IBOutlet UILabel *placeholder;
@property (strong, nonatomic) IBOutlet UITextField *num;
@end
@implementation BuyDetailFooterView
- (void)awakeFromNib{
    [super awakeFromNib];
}
- (IBAction)actionForBtn:(UIButton *)sender {
    if (sender.tag == 201) {///减
        int num = [self.num.text intValue];
        num = num <= 1 ? num : num-1;
        self.num.text = [NSString stringWithFormat:@"%d",num];
    }else if (sender.tag == 202){///加
        int num = [self.num.text intValue];
        num += 1;
        self.num.text = [NSString stringWithFormat:@"%d",num];
    }else if (sender.tag == 203){
        self.model.payNum = self.num.text;
        [[self currentVC] dismissViewControllerAnimated:YES completion:nil];
        if (self.block) {
            self.block();
        }
    }
}
- (void)setModel:(Goods *)model{
    if (_model != model) {
        _model = model;
        self.num.text = self.model.payNum;
    }
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    self.placeholder.hidden = YES;
    return YES;
}
- (BOOL)textViewShouldEndEditing:(UITextView *)textView{
    self.placeholder.hidden = textView.text.length > 0;
    return YES;
}
@end
